function request(params, isHeader = false) {
    return new Promise((resolve, reject) => {
        // 显示loading
        wx.showLoading({
            title: '加载中',
            mask: true,
            success: (res) => { },
            fail: (res) => { },
            complete: (res) => { },
        })

        wx.request({
            ...params,
            url: 'http://localhost:5000' + params.url,
            success: (result) => {
                // console.log(result.header["X-Total-Count"])
                if (isHeader) {
                    resolve({
                        list: result.data,
                        total: result.header["X-Total-Count"]
                    })
                } else {
                    resolve(result.data)
                }
            },
            fail: (res) => {
                reject(res)
            },
            complete: (res) => {
                // 隐藏loading
                wx.hideLoading({
                    success: (res) => { },
                    fail: (res) => { },
                    complete: (res) => { },
                })
            },
        })
    })
}

export default request